package com.jinan;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }


    /**
     * 554.砖墙
     * @param wall
     * @return
     */
    public int leastBricks(List<List<Integer>> wall){
        HashMap<Integer,Integer> map = new HashMap<>();
        for (List<Integer> row : wall) {
            int gap = 0;
            for (int i = 0; i < row.size() - 1; i++){
                gap += row.get(i);
                if(map.containsKey(gap)){
                    map.put(gap,map.get(gap) + 1);
                }else{
                    map.put(gap,1);
                }
            }
        }
        int max = 0;
        for (Integer key : map.keySet()) {
            max = Math.max(max,map.get(key));
        }
        return wall.size() - max;
    }

    public int[] test01(){
        return null;
    }
}